package com.qf.lanzhou.blog.api.controller.comment;

import com.qf.lanzhou.blog.api.controller.BaseServletPost;
import com.qf.lanzhou.blog.api.service.CommentService;
import com.qf.lanzhou.blog.api.service.impl.CommentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 是柠檬甜
 * @ClassName CommentChangeStatusServlet
 * @description 评论修改读取状态功能
 * @date 2020/12/17 21:54
 * @modifier 是柠檬甜
 * @date 2020-12-17 21:54
 * @Version V1.0
 */
@WebServlet("/commentChangeStatus.do")
public class CommentChangeStatusServlet extends BaseServletPost {
    private CommentService commentService=new CommentServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String commentId = req.getParameter("commentId");
        try{
            Boolean status = commentService.changeStatus(commentId);
            successResultWrite("读取成功",resp);
        }catch(RuntimeException e){
            String message = e.getMessage();
            failedResultWrite(message,resp);
        }


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}

